package scedu.controller;

import com.scedu.springcloud.entity.Dept;
import com.scedu.springcloud.service.DeptClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

//提供feign注入服务
@RestController
@Slf4j
public class DeptConsumerController {

    @Autowired
    DeptClientService deptClientService;

    /*查询单个

     */
    @GetMapping("/get/{id}")
    public Dept get( @PathVariable("id") Long id){
        log.info("输入的id是{}",id);
        return deptClientService.queryById(id);
    }
    /*添加

     */
    @PostMapping("/add")
    public Integer add(Dept dept){

     return  deptClientService.addDept(dept);
    }
    /*查询所有

     */
    @GetMapping("/all")
    public List<Dept> queryALL()
    {
        return deptClientService.queryALL();
    }
}
